home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / Container / Sources / Proxy.cpp < prev    next >
Encoding:
Text File  |  1996-09-17  |  20.2 KB  |  688 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                Proxy.cpp
  4. //    Release Version:    $ ODF 2 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "Container.hpp"
  11.  
  12. #ifndef PROXY_H
  13. #include "Proxy.h"
  14. #endif
  15.  
  16. #ifndef PART_H
  17. #include "Part.h"
  18. #endif
  19.  
  20. #ifndef FRAME_H
  21. #include "Frame.h"
  22. #endif
  23.  
  24. // ----- Part Layer -----
  25.  
  26. #ifndef FWITERS_H
  27. #include "FWIters.h"
  28. #endif
  29.  
  30. #ifndef FWPXYITE_H
  31. #include "FWPxyIte.h"
  32. #endif
  33.  
  34. #ifndef FWUTIL_H
  35. #include "FWUtil.h"
  36. #endif
  37.  
  38. #ifndef FWPART_H
  39. #include "FWPart.h"
  40. #endif
  41.  
  42. #ifndef FWPRTITE_H
  43. #include "FWPrtIte.h"
  44. #endif
  45.  
  46. #ifndef FWPRESEN_H
  47. #include "FWPresen.h"
  48. #endif
  49.  
  50. #ifndef FWPXYFRM_H
  51. #include "FWPxyFrm.h"
  52. #endif
  53.  
  54. #ifndef FWFCTCLP_H
  55. #include "FWFctClp.h"
  56. #endif
  57.  
  58. // ----- OS Layer -----
  59.  
  60. #ifndef FWRECT_H
  61. #include "FWRect.h"
  62. #endif
  63.  
  64. #ifndef FWODGEOM_H
  65. #include "FWODGeom.h"
  66. #endif
  67.  
  68. #ifndef FWEVENT_H
  69. #include "FWEvent.h"
  70. #endif
  71.  
  72. #ifndef FWINK_H
  73. #include "FWInk.h"
  74. #endif
  75.  
  76. #ifndef FWSTYLE_H
  77. #include "FWStyle.h"
  78. #endif
  79.  
  80. #ifndef FWLINSHP_H
  81. #include "FWLinShp.h"
  82. #endif
  83.  
  84. #ifndef SLSHATTR_H
  85. #include "SLShAttr.h"
  86. #endif
  87.  
  88. #ifndef FWRECSHP_H
  89. #include "FWRecShp.h"
  90. #endif
  91.  
  92. #ifndef FWGRUTIL_H
  93. #include "FWGrUtil.h"
  94. #endif
  95.  
  96. #ifndef FWBARRAY_H
  97. #include "FWBArray.h"
  98. #endif
  99.  
  100. // ----- Foundation Includes -----
  101.  
  102. #ifndef FWSTREAM_H
  103. #include "FWStream.h"
  104. #endif
  105.  
  106. // ----- OpenDoc Includes -----
  107.  
  108. #ifndef SOM_ODShape_xh
  109. #include <Shape.xh>
  110. #endif
  111.  
  112. #ifndef SOM_ODTransform_xh
  113. #include <Trnsform.xh>
  114. #endif
  115.  
  116. #ifndef SOM_ODStorageUnitView_xh
  117. #include <SUView.xh>
  118. #endif
  119.  
  120. //========================================================================================
  121. //    Runtime Information
  122. //========================================================================================
  123.  
  124. #ifdef FW_BUILD_MAC
  125. #pragma segment odfcontainer
  126. #endif
  127.  
  128. //========================================================================================
  129. // Globals
  130. //========================================================================================
  131.  
  132. FW_CRectShape* CProxy::fgWorkingHandle = NULL;
  133. unsigned long CProxy::fgProxyCount = 0;
  134.  
  135. //========================================================================================
  136. //    CProxy
  137. //========================================================================================
  138.  
  139. //----------------------------------------------------------------------------------------
  140. //    CProxy::CProxy
  141. //----------------------------------------------------------------------------------------
  142.  
  143. CProxy::CProxy(Environment* ev, const FW_CRect& bounds, CContainerPart* part, ODTypeToken viewAs) :
  144.     FW_MProxy(ev, part),
  145.     fContainerPart(part),
  146.     fBounds(bounds),
  147.     fSelected(false),
  148.     fViewAs(viewAs),
  149.     fChanged(FALSE)
  150. {
  151.     InitStatic();
  152.     CProxy::fgProxyCount++;
  153. }
  154.  
  155. //----------------------------------------------------------------------------------------
  156. // CProxy::~CProxy
  157. //----------------------------------------------------------------------------------------
  158.  
  159. CProxy::~CProxy()
  160. {
  161.     CProxy::fgProxyCount--;
  162.     if (CProxy::fgProxyCount == 0)
  163.         delete CProxy::fgWorkingHandle;
  164. }
  165.     
  166. //----------------------------------------------------------------------------------------
  167. //    CProxy::InitStatic
  168. //----------------------------------------------------------------------------------------
  169.  
  170. void CProxy::InitStatic()
  171. {
  172.     if (fgProxyCount == 0)
  173.     {
  174.         CProxy::fgWorkingHandle = FW_NEW(FW_CRectShape, (FW_kZeroRect, FW_kFill));
  175.         CProxy::fgWorkingHandle->SetInk(FW_kInvertInk);
  176.     }
  177. }
  178.  
  179. //----------------------------------------------------------------------------------------
  180. //    CProxy::FrameShapeRequested
  181. //----------------------------------------------------------------------------------------
  182.  
  183. ODShape* CProxy::FrameShapeRequested(Environment* ev, 
  184.                                      FW_CEmbeddingFrame* embeddingFrame, 
  185.                                      ODFrame* odEmbeddedFrame, 
  186.                                      ODShape* requestedFrameShape)
  187. {
  188. FW_UNUSED(embeddingFrame);
  189.     // ----- get the bounding box of the asked frame shape
  190.     FW_CRect frameRect = FW_GetShapeBoundingBox(ev, requestedFrameShape);
  191.     
  192.     if (fSelected)
  193.         InvalidateHandles(ev, (CContainerFrame*)embeddingFrame);
  194.  
  195.     fBounds.right = fBounds.left + frameRect.Width();
  196.     fBounds.bottom = fBounds.top + frameRect.Height();
  197.  
  198.     fChanged = TRUE;
  199.     
  200.     if (fSelected)
  201.         InvalidateHandles(ev, (CContainerFrame*)embeddingFrame);
  202.  
  203.     // ----- Invalidate the old used Shape in case the embedded frame doesn't do it-----
  204.     FW_CAcquiredODShape aqUsedShape = odEmbeddedFrame->AcquireUsedShape(ev, NULL);
  205.     odEmbeddedFrame->Invalidate(ev, aqUsedShape, NULL);
  206.     
  207.     // ----- Don't forget to bump the refcount
  208.     requestedFrameShape->Acquire(ev);
  209.     return requestedFrameShape;
  210. }
  211.  
  212. //----------------------------------------------------------------------------------------
  213. //    CProxy::UsedShapeChanged
  214. //----------------------------------------------------------------------------------------
  215.  
  216. void CProxy::UsedShapeChanged(Environment* ev, FW_CEmbeddingFrame* embeddingFrame, ODFrame* odEmbeddedFrame)
  217. {
  218. FW_UNUSED(odEmbeddedFrame);
  219.  
  220.     // ----- Recalcul the clip -----
  221.     FW_CAcquiredODShape changedShape = ::FW_NewODShape(ev, fBounds);
  222.     FW_CFacetClipper facetClipper;
  223.     facetClipper.Clip(ev, embeddingFrame, NULL /*changedShape*/);
  224.  
  225.     // ----- Invalidate
  226.     embeddingFrame->Invalidate(ev, fBounds);
  227. }
  228.  
  229. //----------------------------------------------------------------------------------------
  230. // CProxy::GetHandleCenter
  231. //----------------------------------------------------------------------------------------
  232.  
  233. void CProxy::GetHandleCenter(short whichHandle, FW_CPoint& center) const
  234. {
  235.     const FW_Fixed fxHalf = FW_ODFixedToFixed(0x00008000);
  236.     const FW_Fixed fxTwo = FW_IntToFixed(2);
  237.     const FW_Fixed fxThree = FW_IntToFixed(3);
  238.  
  239.     switch (whichHandle)
  240.     {
  241.         case kInTopLeftCorner:
  242.             center.x = fBounds.left - fxThree;
  243.             center.y = fBounds.top - fxThree;
  244.             break;
  245.         case kInTopRightCorner:
  246.             center.x = fBounds.right + fxTwo;
  247.             center.y = fBounds.top - fxThree;
  248.             break;
  249.         case kInBottomLeftCorner:
  250.             center.x = fBounds.left - fxThree;
  251.             center.y = fBounds.bottom + fxTwo;
  252.             break;
  253.         case kInBottomRightCorner:
  254.             center.x = fBounds.right + fxTwo;
  255.             center.y = fBounds.bottom + fxTwo;
  256.             break;
  257.  
  258.         case kInTopMiddle:
  259.             center.x = fBounds.left + (fBounds.Width() * fxHalf);
  260.             center.y = fBounds.top - fxThree;
  261.             break;
  262.         case kInLeftMiddle:
  263.             center.x = fBounds.left - fxThree;
  264.             center.y = fBounds.top + (fBounds.Height() * fxHalf);
  265.             break;
  266.         case kInBottomMiddle:
  267.             center.x = fBounds.left + (fBounds.Width() * fxHalf);
  268.             center.y = fBounds.bottom + fxTwo;
  269.             break;
  270.         case kInRightMiddle:
  271.             center.x = fBounds.right + fxTwo;
  272.             center.y = fBounds.top + (fBounds.Height() * fxHalf);
  273.             break;
  274.     }
  275. }
  276.  
  277.  
  278. //----------------------------------------------------------------------------------------
  279. // CProxy::ResizeProxy
  280. //----------------------------------------------------------------------------------------
  281.  
  282. void CProxy::ResizeProxy(Environment* ev, const FW_CRect& srcRect, const FW_CRect& dstRect)
  283. {
  284.     FW_CRect bounds(fBounds);
  285.     bounds.Map(srcRect, dstRect);    
  286.     bounds.Sort();
  287.     
  288.     SetBounds(ev, bounds);
  289. }
  290.  
  291. //----------------------------------------------------------------------------------------
  292. // CProxy::OffsetProxy
  293. //----------------------------------------------------------------------------------------
  294.  
  295. void CProxy::OffsetProxy(Environment* ev, FW_Fixed xDelta, FW_Fixed yDelta)
  296. {    
  297.     FW_CRect bounds(fBounds);
  298.     bounds.Offset(xDelta, yDelta);
  299.     SetBounds(ev, bounds);
  300. }
  301.         
  302. //----------------------------------------------------------------------------------------
  303. // CProxy::SelectProxy
  304. //----------------------------------------------------------------------------------------
  305. void CProxy::SelectProxy(Environment* ev, FW_Boolean state)
  306. {
  307.     fSelected = state;
  308.     
  309.     // ----- Select all the embedded facet ----
  310.     SetSelectState(ev, state);
  311. }
  312.  
  313. //----------------------------------------------------------------------------------------
  314. // CProxy::SubtractToWindowClip
  315. //----------------------------------------------------------------------------------------
  316. //    ATTENTION: windowClip is in Window coordinates. tempShape is just a working shape. It is
  317. //    used by CProxy so I don't have to allocate a shape every time.
  318.  
  319. void CProxy::SubtractToWindowClip(Environment* ev, 
  320.                                   FW_CFacetClipper* facetClipper, 
  321.                                   ODFacet* containingFacet, 
  322.                                   ODShape* windowClip, 
  323.                                   ODShape* tempShape)
  324. {
  325. FW_UNUSED(tempShape);
  326.  
  327.     FW_CEmbeddedODFacetsIterator ite(ev, this, containingFacet, kODFrontToBack);
  328.     for (ODFacet *embeddedODFacet = ite.First(ev); ite.IsNotComplete(ev); embeddedODFacet = ite.Next(ev))
  329.     {
  330.         facetClipper->ClipOneEmbeddedFacet(ev, embeddedODFacet, windowClip);
  331.     }
  332. }
  333.  
  334. //----------------------------------------------------------------------------------------
  335. // CProxy::HitTest
  336. //----------------------------------------------------------------------------------------
  337.  
  338. FW_Boolean CProxy::HitTest(Environment* ev, FW_CGraphicContext& gc, const FW_CPoint& where) const
  339. {    
  340. FW_UNUSED(ev);
  341.     FW_CRectShape rectShape(fBounds, FW_kFill);
  342.     return rectShape.HitTest(gc, where, FW_kFixed0);
  343. }
  344.  
  345. //----------------------------------------------------------------------------------------
  346. // CProxy::CalcHandle
  347. //----------------------------------------------------------------------------------------
  348.  
  349. void CProxy::CalcHandle(short whichHandle, FW_CRectShape* handle, FW_Fixed penSize) const
  350. {
  351.     FW_CRect rect;
  352.     CalcHandle(whichHandle, rect, penSize);
  353.     handle->SetRectangle(rect);
  354. }
  355.  
  356. //----------------------------------------------------------------------------------------
  357. // CProxy::CalcHandle
  358. //----------------------------------------------------------------------------------------
  359.  
  360. void CProxy::CalcHandle(short whichHandle, FW_CRect& rect, FW_Fixed penSize) const
  361. {
  362.     FW_CPoint pt;
  363.     GetHandleCenter(whichHandle, pt);
  364.     rect.Set(pt.x - penSize, pt.y - penSize, pt.x + penSize, pt.y + penSize);
  365. }
  366.  
  367. //----------------------------------------------------------------------------------------
  368. // CProxy::RenderSelectionFrame
  369. //----------------------------------------------------------------------------------------
  370.  
  371. void CProxy::RenderSelectionFrame(FW_CGraphicContext& gc)
  372. {
  373.     FW_CInk ink(FW_kRGBBlack, FW_kRGBWhite, FW_kXOr);
  374.     FW_CStyle style(FW_kFixed0, FW_kGrayPat);
  375.     
  376.     FW_CRect rect;
  377.     GetHandleCenter(kInTopLeftCorner, rect[FW_kTopLeft]);
  378.     GetHandleCenter(kInBottomRightCorner, rect[FW_kBotRight]);
  379.     rect[FW_kBotRight] += FW_CPoint(FW_kFixedPos1, FW_kFixedPos1);    // adjust for penSize
  380.     FW_CRectShape::RenderRect(gc, rect, FW_kFrame, ink, style);
  381. }
  382.  
  383. //----------------------------------------------------------------------------------------
  384. // CProxy::RenderHandles
  385. //----------------------------------------------------------------------------------------
  386.  
  387. void CProxy::RenderHandles(FW_CGraphicContext& gc, FW_Fixed zoomFactor)
  388. {
  389.     FW_Fixed penSize = CalcHandlePenSize(zoomFactor);
  390.  
  391.     // First draw the lines connecting the handles
  392.     RenderSelectionFrame(gc);
  393.     
  394.     // Now draw the handles themselves
  395.     for (short i=1; i<=kNumberOfHandles; i++)
  396.     {
  397.         CalcHandle(i, CProxy::fgWorkingHandle, penSize);    
  398.         CProxy::fgWorkingHandle->Render(gc);
  399.     }
  400. }
  401.  
  402. //----------------------------------------------------------------------------------------
  403. // CProxy::InvalidateHandles
  404. //----------------------------------------------------------------------------------------
  405.  
  406. void CProxy::InvalidateHandles(Environment* ev, CContainerFrame* frame)
  407. {
  408.     FW_CAcquiredODShape workingShape1 = FW_NewODShape(ev);
  409.     FW_CAcquiredODShape workingShape2 = FW_NewODShape(ev);
  410.     InvalidateHandles(ev, frame->GetContentView(ev), workingShape1, workingShape2, CalcHandlePenSize(frame->GetZoomFactor()));
  411. }
  412.  
  413. //----------------------------------------------------------------------------------------
  414. // CProxy::InvalidateHandles
  415. //----------------------------------------------------------------------------------------
  416.  
  417. void CProxy::InvalidateHandles(Environment* ev, 
  418.                             FW_CView* contentView, 
  419.                             ODShape* workingShape1, 
  420.                             ODShape* workingShape2, 
  421.                             FW_Fixed penSize)
  422. {
  423.     FW_CRect rect, finalRect;
  424.     CalcHandle(kInTopLeftCorner, finalRect, penSize);
  425.     CalcHandle(kInBottomRightCorner, rect, penSize);
  426.     finalRect.Union(rect);
  427.  
  428.     workingShape1->SetRectangle(ev, finalRect);
  429.     workingShape2->SetRectangle(ev, fBounds);
  430.     workingShape1->Subtract(ev, workingShape2);
  431.     
  432.     contentView->Invalidate(ev, workingShape1);
  433. }
  434.  
  435. //----------------------------------------------------------------------------------------
  436. // CProxy::WhichHandle
  437. //----------------------------------------------------------------------------------------
  438.  
  439. short CProxy::WhichHandle(FW_CGraphicContext& gc, const FW_CPoint& mouse, FW_Fixed zoomFactor) const
  440. {
  441.     FW_Fixed penSize = CalcHandlePenSize(zoomFactor);
  442.     for (short i=1; i<=kNumberOfHandles; i++)
  443.     {
  444.         CalcHandle(i, CProxy::fgWorkingHandle, penSize);
  445.         if (CProxy::fgWorkingHandle->HitTest(gc, mouse, FW_kFixed0))
  446.             return i;
  447.     }
  448.         
  449.     return 0;
  450. }
  451.  
  452. //----------------------------------------------------------------------------------------
  453. // CProxy::CreateProxyOutline
  454. //----------------------------------------------------------------------------------------
  455.  
  456. ODShape* CProxy::CreateProxyOutline(Environment* ev)
  457. {
  458.     // We don't acquire it because we return it
  459.     ODShape* dragShape = ::FW_NewODShape(ev, fBounds);
  460.  
  461.     ::FW_OutlineODShape(ev, dragShape, FW_kFixed0);
  462.  
  463.     return dragShape;
  464. }
  465.  
  466. //----------------------------------------------------------------------------------------
  467. // CProxy::GetMappedRects
  468. //----------------------------------------------------------------------------------------
  469.  
  470. void CProxy::GetMappedRects(short whichHandle, const FW_CPoint& mouseLoc, FW_CRect& srcRect, FW_CRect& dstRect)
  471. {
  472.     dstRect = srcRect = fBounds;
  473.     
  474.     switch (whichHandle)
  475.     {
  476.         case kInTopLeftCorner:
  477.             dstRect.left = mouseLoc.x;
  478.             dstRect.top = mouseLoc.y;
  479.             break;
  480.         case kInTopRightCorner:
  481.             dstRect.right = mouseLoc.x;
  482.             dstRect.top = mouseLoc.y;
  483.             break;
  484.         case kInBottomLeftCorner:
  485.             dstRect.left = mouseLoc.x;
  486.             dstRect.bottom = mouseLoc.y;
  487.             break;
  488.         case kInBottomRightCorner:
  489.             dstRect.right = mouseLoc.x;
  490.             dstRect.bottom = mouseLoc.y;
  491.             break;
  492.  
  493.         case kInTopMiddle:
  494.             dstRect.top = mouseLoc.y;
  495.             break;
  496.         case kInLeftMiddle:
  497.             dstRect.left = mouseLoc.x;
  498.             break;
  499.         case kInBottomMiddle:
  500.             dstRect.bottom = mouseLoc.y;
  501.             break;
  502.         case kInRightMiddle:
  503.             dstRect.right = mouseLoc.x;
  504.             break;
  505.     }
  506. }
  507.  
  508. //----------------------------------------------------------------------------------------
  509. // CProxy::ResizeFeedback
  510. //----------------------------------------------------------------------------------------
  511.  
  512. void CProxy::ResizeFeedback(FW_CGraphicContext& gc, 
  513.                             const FW_CInk& ink, 
  514.                             const FW_CStyle& style, 
  515.                             short whichHandle, 
  516.                             const FW_CPoint& mouseLoc)
  517. {
  518.     FW_CRect srcRect, dstRect;
  519.     GetMappedRects(whichHandle, mouseLoc, srcRect, dstRect);
  520.     dstRect.Inset(FW_IntToFixed(-3) - FW_Half(style.GetPenSize()));
  521.  
  522.     dstRect.Sort();
  523.     
  524.     FW_CRectShape::RenderRect(gc,
  525.                               dstRect,
  526.                               FW_kFrame,
  527.                               ink, 
  528.                               style);
  529. }
  530.  
  531. //----------------------------------------------------------------------------------------
  532. // CProxy::InSelectionRect
  533. //----------------------------------------------------------------------------------------
  534.  
  535. FW_Boolean CProxy::InSelectionRect(const FW_CRect& selectRect) const
  536. {
  537.     FW_CRect temp(fBounds);
  538.     temp.Intersection(selectRect);
  539.     
  540.     return fBounds == temp;
  541. }
  542.  
  543. //----------------------------------------------------------------------------------------
  544. // CProxy::GetUpdateBox
  545. //----------------------------------------------------------------------------------------
  546.  
  547. void CProxy::GetUpdateBox(Environment* ev, ODShape* updateBox) const
  548. {
  549.     FW_CRect bounds(fBounds);
  550.     bounds.Inset(FW_IntToFixed(-6));
  551.     updateBox->SetRectangle(ev, (ODRect*)&bounds);
  552. }
  553.  
  554. //----------------------------------------------------------------------------------------
  555. // CProxy::SetBounds
  556. //----------------------------------------------------------------------------------------
  557.  
  558. void CProxy::SetBounds(Environment* ev, const FW_CRect& bounds)
  559. {
  560.     fBounds = bounds;
  561.     fChanged = TRUE;
  562.     
  563.     // ----- Resize/Move every embedded frame -----
  564.     ChangeExternalTransforms(ev, fBounds.left, fBounds.top);
  565.     ChangeFrameShapes(ev, fBounds.right - fBounds.left, fBounds.bottom - fBounds.top);
  566. }
  567.  
  568. //----------------------------------------------------------------------------------------
  569. // CProxy::Render
  570. //----------------------------------------------------------------------------------------
  571. //    Because there can be multiple CProxy pointing on an embedded
  572. //    frame, I only draw those belonging to this frame.
  573.  
  574. void CProxy::Render(Environment *ev, ODFacet* facet, FW_CGraphicContext& gc)
  575. {
  576.     // if the canvas is not dynamic (printing) I let OpenDoc draw embedded facets
  577.     if (!facet->GetCanvas(ev)->IsDynamic(ev))
  578.         return;
  579.         
  580.     FW_CAcquiredODShape aqTempShape = ::FW_NewODShape(ev);
  581.     FW_CAcquiredODShape aqTempClipShape(gc.AcquireClip());    // GetClip returns a copy in content coordinate
  582.  
  583.     // ----- Because we are calling the draw method of an embedded facet, we want
  584.     // ----- to save our context. The embedded facet will be using the same grafport 
  585.     // ----- and may not be restoring it.    
  586.     FW_CSaveRestoreContext src(gc);
  587.     
  588.     FW_CEmbeddedODFacetsIterator ite(ev, this, facet, kODFrontToBack);
  589.     for (ODFacet *embeddedODFacet = ite.First(ev); ite.IsNotComplete(ev); embeddedODFacet = ite.Next(ev))
  590.     {    
  591.         aqTempShape->CopyFrom(ev, aqTempClipShape);
  592.         
  593.         {
  594.             FW_CAcquiredODTransform aqFrameTransform = embeddedODFacet->AcquireExternalTransform(ev, NULL);
  595.             aqTempShape->InverseTransform(ev, aqFrameTransform);    // parent content (me) -> embedded frame
  596.         }
  597.                 
  598. #ifdef FW_BUILD_WIN
  599.         // [HLX] bug in windows? the invalidShape is expected to be in pixels instead of points
  600.         aqTempShape->Outset(ev, ff(1));    // [HLX] Because of rounding errors
  601.         FW_CGraphicDevice *device = gc.GetGraphicDevice();
  602.         device->PointToPixel(ev, aqTempShape);
  603. #endif
  604.     
  605.         embeddedODFacet->Draw(ev, aqTempShape, NULL);
  606.         embeddedODFacet->DrawChildren(ev, aqTempShape, NULL);
  607.         
  608.         {
  609.             FW_CAcquiredODShape aqClipShape = embeddedODFacet->AcquireClipShape(ev, NULL);
  610.             aqTempShape->CopyFrom(ev, aqClipShape);
  611.         }
  612.         
  613.         {
  614.             FW_CAcquiredODTransform aqExternalTransform = embeddedODFacet->AcquireExternalTransform(ev, NULL);
  615.             aqTempShape->Transform(ev, aqExternalTransform);
  616.         }
  617.         
  618.         aqTempClipShape->Subtract(ev, aqTempShape);
  619.     }
  620. }
  621.  
  622. //----------------------------------------------------------------------------------------
  623. // CProxy::ChangeViewAs
  624. //----------------------------------------------------------------------------------------
  625.  
  626. void CProxy::ChangeViewAs(Environment* ev, ODTypeToken viewAs)
  627. {
  628.     fViewAs = viewAs;
  629.     ChangeEmbeddedFramesViewType(ev, fViewAs);
  630. }
  631.  
  632. //----------------------------------------------------------------------------------------
  633. // CProxy::Internalize
  634. //----------------------------------------------------------------------------------------
  635.  
  636. void CProxy::Internalize(Environment* ev, 
  637.                         ODStorageUnitView* sourceSUView,
  638.                         FW_CCloneInfo *cloneInfo)
  639. {
  640.     FW_MProxy::Internalize(ev, sourceSUView, cloneInfo);
  641.     
  642.     FW_CByteArray byteArray;
  643.     sourceSUView->GetValue(ev, sizeof(fViewAs), byteArray);
  644.     byteArray.CopyBuffer(&fViewAs, sizeof(fViewAs));
  645. }
  646.  
  647. //----------------------------------------------------------------------------------------
  648. //    CProxy::Externalize
  649. //----------------------------------------------------------------------------------------
  650.  
  651. void CProxy::Externalize(Environment* ev, 
  652.                         ODStorageUnitView* destinationSUView, 
  653.                         FW_CCloneInfo* cloneInfo)
  654. {
  655.     FW_MProxy::Externalize(ev, destinationSUView, cloneInfo);
  656.  
  657.     FW_CByteArray byteArray(&fViewAs, sizeof(fViewAs));
  658.     destinationSUView->SetValue(ev, byteArray);
  659. }
  660.  
  661. //----------------------------------------------------------------------------------------
  662. //    CProxy::CreateFacets
  663. //----------------------------------------------------------------------------------------
  664.  
  665. short CProxy::CreateFacets(Environment* ev,
  666.                             FW_CEmbeddingFrame* embeddingFrame,
  667.                             ODFacet* embeddingFacet,
  668.                             ODFrame* embeddedFrame,
  669.                             ODShape* proposedClipShape)
  670. {
  671. FW_UNUSED(embeddingFrame);
  672.     FW_CRect embeddedFrameBounds = GetBounds(ev);
  673.     
  674.     FW_CAcquiredODTransform aqExternalTransform = ::FW_NewODTransform(ev, embeddedFrameBounds.TopLeft());
  675.  
  676.     CreateFacet(ev,
  677.                 embeddingFacet,
  678.                 embeddedFrame,
  679.                 proposedClipShape,
  680.                 aqExternalTransform,
  681.                 NULL,                    // Canvas
  682.                 NULL,                    // biasCanvas
  683.                 NULL,                    // siblingFacet
  684.                 kODFrameInFront);
  685.     return 1;
  686. }
  687.  
  688.